import { PSControlImpl } from '../pscontrol-impl';
import { IPSDEToolbar } from './ipsdetoolbar';
import { IPSDEToolbarItem } from './ipsdetoolbar-item';

export class PSDEToolbarImpl extends PSControlImpl implements IPSDEToolbar {
  get owner(): IModel {
    return this.M.owner;
  }

  protected psdetoolbaritems: IPSDEToolbarItem[] | null = null;

  getPSDEToolbarItems(): IPSDEToolbarItem[] | null {
    if (this.psdetoolbaritems == null) {
      this.psdetoolbaritems = this.fillChildListModel(this.M.getPSDEToolbarItems, 'control.toolbar.IPSDEToolbarItem') as IPSDEToolbarItem[];
    }
    return this.psdetoolbaritems;
  }

  get psDEToolbarItems(): IPSDEToolbarItem[] | null {
    return this.getPSDEToolbarItems();
  }

  findPSDEToolbarItem(objKey: any): IPSDEToolbarItem | null {
    return this.getPSModel5('control.toolbar.IPSDEToolbarItem', this.getPSDEToolbarItems(), objKey) as IPSDEToolbarItem;
  }

  get toolbarStyle(): string {
    return this.M.toolbarStyle;
  }

  get xDataControlName(): string {
    return this.M.xDataControlName;
  }

  get cls(): string {
    return 'PSDEToolbarImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.toolbar.IPSDEToolbar') return true;
    return super.instanceof(cls);
  }
}
